clear all
set more off
cd "D:/Dropbox/coauthors/AMT_Bisbee_Larson/"
********************************************************************************
* File Name: data-prep.do
* 
* Input Files: AMT_Test_Qualtrics.csv
* Output Files: final_data_clean.dta
*               data_prepped.dta
*               final_data_long.dta
* Purpose: The purpose of this file is to clean the data by
*   1) removing respondents who failed the attention questions
*   2) removing respondents who completed the survey in under 5 minutes
*   3) creating dummy variables for the various demographic categories
********************************************************************************

clear all
insheet using "./bisbee_larson_replication_final/tools/Roll-out-3-14-2015/Thursday/AMT_Test_Qualtrics.csv"

foreach var of varlist * {
  label variable `var' "`=`var'[1]'"
}

drop if _n == 1

ren q284 Disclaimer
ren v9 Instructions
ren q43 online_offline
ren q1 weakest_name
ren q2 weak_name
ren q3 strong_name
ren q4 strongest_name
ren q87 test1
ren q5 clique_name
ren q96 drop5
ren q97_6_group prof_crisis_group_weakest
ren q97_6_rank prof_crisis_rank_weakest
ren q97_7_group prof_crisis_group_weak
ren q97_7_rank prof_crisis_rank_weak
ren q97_8_group prof_crisis_group_strong
ren q97_8_rank prof_crisis_rank_strong
ren q97_9_group prof_crisis_group_strongest
ren q97_9_rank prof_crisis_rank_strongest
ren q97_10_group prof_crisis_group_clique
ren q97_10_rank prof_crisis_rank_clique
ren q47_6_group personal_crisis_group_weakest
ren q47_6_rank personal_crisis_rank_weakest
ren q47_7_group personal_crisis_group_weak
ren q47_7_rank personal_crisis_rank_weak
ren q47_8_group personal_crisis_group_strong
ren q47_8_rank personal_crisis_rank_strong
ren q47_9_group personal_crisis_group_strongest
ren q47_9_rank personal_crisis_rank_strongest
ren q47_10_group personal_crisis_group_clique
ren q47_10_rank personal_crisis_rank_clique
ren q98_1_group prof_success_group_weakest
ren q98_1_rank prof_success_rank_weakest
ren q98_2_group prof_success_group_weak
ren q98_2_rank prof_success_rank_weak
ren q98_3_group prof_success_group_strong
ren q98_3_rank prof_success_rank_strong
ren q98_4_group prof_success_group_strongest
ren q98_4_rank prof_success_rank_strongest
ren q98_5_group prof_success_group_clique
ren q98_5_rank prof_success_rank_clique
ren q48_1_group personal_success_group_weakest
ren q48_1_rank personal_success_rank_weakest
ren q48_2_group personal_success_group_weak
ren q48_2_rank personal_success_rank_weak
ren q48_3_group personal_success_group_strong
ren q48_3_rank personal_success_rank_strong
ren q48_4_group personal_success_group_strongest
ren q48_4_rank personal_success_rank_strongest
ren q48_5_group personal_success_group_clique
ren q48_5_rank personal_success_rank_clique
ren q74 drop6
ren q82 drop7
ren q99_1_group seat_least_weakest
ren q99_1_rank drop8
ren q99_2_group seat_least_weak
ren q99_2_rank drop9
ren q99_3_group seat_least_strong
ren q99_3_rank drop10
ren q99_4_group seat_least_strongest
ren q99_4_rank drop11
ren q99_5_group seat_least_clique
ren q99_5_rank drop12
ren q99_6_group seat_least_you
ren q99_6_rank drop13
ren q100_1_group seat_most_weakest
ren q100_1_rank drop14
ren q100_2_group seat_most_weak
ren q100_2_rank drop15
ren q100_3_group seat_most_strong
ren q100_3_rank drop16
ren q100_4_group seat_most_strongest
ren q100_4_rank drop17
ren q100_5_group seat_most_clique
ren q100_5_rank drop18
ren q100_6_group seat_most_you
ren q100_6_rank drop19
ren q101_1 tie_weakest
ren q101_2 tie_weak
ren q101_3 tie_strong
ren q101_4 tie_strongest
ren q101_5 tie_clique
ren q139 drop20
ren q140 homophily_political
ren q141 homophily_religious
ren q142 homophily_education
ren q143 homophily_life_skills
ren q144 game_political
ren q145 game_religion
ren q150 drop21
ren q151_1 jobsearch_weakest
ren q151_2 jobsearch_weak
ren q151_3 jobsearch_strong
ren q151_4 jobsearch_strongest
ren q151_5 jobsearch_clique
ren q152_1 contribute_weakest
ren q152_2 contribute_weak
ren q152_3 contribute_strong
ren q152_4 contribute_strongest
ren q152_5 contribute_clique
ren q153_1 garner_weakest
ren q153_2 garner_weak
ren q153_3 garner_strong
ren q153_4 garner_strongest
ren q153_5 garner_clique
ren q183 drop22
ren q184_1 donate_weakest
ren q184_2 donate_weak
ren q184_3 donate_strong
ren q184_4 donate_strongest
ren q184_5 donate_clique
ren q184_6 donate_you
ren q185_1 personalgain_weakest
ren q185_2 personalgain_weak
ren q185_3 personalgain_strong
ren q185_4 personalgain_strongest
ren q185_5 personalgain_clique
ren q186_1 groupgain_weakest
ren q186_2 groupgain_weak
ren q186_3 groupgain_strong
ren q186_4 groupgain_strongest
ren q186_5 groupgain_clique
ren q289 peace_weakest
ren q94 peace_weakest_join
ren q95_2 weak_peace_weakest_inform
ren q95_3 strong_peace_weakest_inform
ren q95_4 strongest_peace_weakest_inform
ren q95_5 clique_peace_weakest_inform
ren q128_2 weak_peace_weakest_prompt
ren q128_3 strong_peace_weakest_prompt
ren q128_4 strongest_peace_weakest_prompt
ren q128_5 clique_peace_weakest_prompt
ren q295 peace_weak
ren q296 peace_weak_join
ren q297_2 weakest_peace_weak_inform
ren q297_3 strong_peace_weak_inform
ren q297_4 strongest_peace_weak_inform
ren q297_5 clique_peace_weak_inform
ren q129_2 weakest_peace_weak_prompt
ren q129_3 strong_peace_weak_prompt
ren q129_4 strongest_peace_weak_prompt
ren q129_5 clique_peace_weak_prompt
ren q298 peace_strong
ren q299 peace_strong_join
ren q300_2 weakest_peace_strong_inform
ren q300_3 weak_peace_strong_inform
ren q300_4 strongest_peace_strong_inform
ren q300_5 clique_peace_strong_inform
ren q130_2 weakest_peace_strong_prompt
ren q130_3 weak_peace_strong_prompt
ren q130_4 strongest_peace_strong_prompt
ren q130_5 clique_peace_strong_prompt
ren q301 peace_strongest
ren q302 peace_strongest_join
ren q303_2 weakest_peace_strongest_inform
ren q303_3 weak_peace_strongest_inform
ren q303_4 strong_peace_strongest_inform
ren q303_5 clique_peace_strongest_inform
ren q131_2 weakest_peace_strongest_prompt
ren q131_3 weak_peace_strongest_prompt
ren q131_4 strong_peace_strongest_prompt
ren q131_5 clique_peace_strongest_prompt
ren q304 peace_clique
ren q305 peace_clique_join
ren q306_2 weakest_peace_clique_inform
ren q306_3 weak_peace_clique_inform
ren q306_4 strong_peace_clique_inform
ren q306_5 strongest_peace_clique_inform
ren q132_2 weakest_peace_clique_prompt
ren q132_3 weak_peace_clique_prompt
ren q132_4 strong_peace_clique_prompt
ren q132_5 strongest_peace_clique_prompt
ren q307 viol_weakest
ren q308 viol_weakest_join
ren q309_2 weak_viol_weakest_inform
ren q309_3 strong_viol_weakest_inform
ren q309_4 strongest_viol_weakest_inform
ren q309_5 clique_viol_weakest_inform
ren q133_2 weak_viol_weakest_prompt
ren q133_3 strong_viol_weakest_prompt
ren q133_4 strongest_viol_weakest_prompt
ren q133_5 clique_viol_weakest_prompt
ren q310 viol_weak
ren q311 viol_weak_join
ren q312_2 weakest_viol_weak_inform
ren q312_3 strong_viol_weak_inform
ren q312_4 strongest_viol_weak_inform
ren q312_5 clique_viol_weak_inform
ren q134_2 weakest_viol_weak_prompt
ren q134_3 strong_viol_weak_prompt
ren q134_4 strongest_viol_weak_prompt
ren q134_5 clique_viol_weak_prompt
ren q313 viol_strong
ren q314 viol_strong_join
ren q315_2 weakest_viol_strong_inform
ren q315_3 weak_viol_strong_inform
ren q315_4 strongest_viol_strong_inform
ren q315_5 clique_viol_strong_inform
ren q135_2 weakest_viol_strong_prompt
ren q135_3 weak_viol_strong_prompt
ren q135_4 strongest_viol_strong_prompt
ren q135_5 clique_viol_strong_prompt
ren q316 viol_strongest
ren q317 viol_strongest_join
ren q318_2 weakest_viol_strongest_inform
ren q318_3 weak_viol_strongest_inform
ren q318_4 strong_viol_strongest_inform
ren q318_5 clique_viol_strongest_inform
ren q136_2 weakest_viol_strongest_prompt
ren q136_3 weak_viol_strongest_prompt
ren q136_4 strong_viol_strongest_prompt
ren q136_5 clique_viol_strongest_prompt
ren q319 viol_clique
ren q320 viol_clique_join
ren q321_2 weakest_viol_clique_inform
ren q321_3 weak_viol_clique_inform
ren q321_4 strong_viol_clique_inform
ren q321_5 strongest_viol_clique_inform
ren q137_2 weakest_viol_clique_prompt
ren q137_3 weak_viol_clique_prompt
ren q137_4 strong_viol_clique_prompt
ren q137_5 strongest_viol_clique_prompt
ren q280_1 interaction_weakest
ren q280_2 interaction_weak
ren q280_3 interaction_strong
ren q280_4 interaction_strongest
ren q280_5 interaction_clique
ren q154 drop40
ren q155 dem_educ
ren q156 dem_age
ren q157 dem_industry
ren q158 dem_occupation
ren q159 dem_race
ren q160 dem_country
ren q161 dem_family
ren q162 dem_gender
ren q163 dem_hhinc
ren q164 dem_marital
ren q75_6 intro_q1
ren q75_7 intro_q2
ren q75_8 intro_q3
ren q75_10 intro_q4
ren q75_11 intro_q5
ren q75_12 intro_q6
ren q75_13 intro_q7
ren q75_14 intro_q8
ren q75_15 intro_q9
ren q75_16 test2

g online = 0
replace online = 1 if weakest_name != ""

sort online


replace weakest_name = q239 if weakest_name == ""
replace weak_name = q240 if weak_name == ""
replace strong_name = q241 if strong_name == ""
replace strongest_name = q242 if strongest_name == ""
replace test1 = q88 if test1 == ""
replace clique_name = q243 if clique_name == ""
replace prof_crisis_group_weakest = q249_6_group if prof_crisis_group_weakest == ""
replace prof_crisis_rank_weakest = q249_6_rank if prof_crisis_rank_weakest == ""
replace prof_crisis_group_weak = q249_7_group if prof_crisis_group_weak == ""
replace prof_crisis_rank_weak = q249_7_rank if prof_crisis_rank_weak == ""
replace prof_crisis_group_strong = q249_8_group if prof_crisis_group_strong == ""
replace prof_crisis_rank_strong = q249_8_rank if prof_crisis_rank_strong == ""
replace prof_crisis_group_strongest = q249_9_group if prof_crisis_group_strongest == ""
replace prof_crisis_rank_strongest = q249_9_rank if prof_crisis_rank_strongest == ""
replace prof_crisis_group_clique = q249_10_group if prof_crisis_group_clique == ""
replace prof_crisis_rank_clique = q249_10_rank if prof_crisis_rank_clique == ""
replace personal_crisis_group_weakest = q250_6_group if personal_crisis_group_weakest == ""
replace personal_crisis_rank_weakest = q250_6_rank if personal_crisis_rank_weakest == ""
replace personal_crisis_group_weak = q250_7_group if personal_crisis_group_weak == ""
replace personal_crisis_rank_weak = q250_7_rank if personal_crisis_rank_weak == ""
replace personal_crisis_group_strong = q250_8_group if personal_crisis_group_strong == ""
replace personal_crisis_rank_strong = q250_8_rank if personal_crisis_rank_strong == ""
replace personal_crisis_group_strongest = q250_9_group if personal_crisis_group_strongest == ""
replace personal_crisis_rank_strongest = q250_9_rank if personal_crisis_rank_strongest == ""
replace personal_crisis_group_clique = q250_10_group if personal_crisis_group_clique == ""
replace personal_crisis_rank_clique = q250_10_rank if personal_crisis_rank_clique == ""
replace prof_success_group_weakest = q251_1_group if prof_success_group_weakest == ""
replace prof_success_rank_weakest = q251_1_rank if prof_success_rank_weakest == ""
replace prof_success_group_weak = q251_2_group if prof_success_group_weak == ""
replace prof_success_rank_weak = q251_2_rank if prof_success_rank_weak == ""
replace prof_success_group_strong = q251_3_group if prof_success_group_strong == ""
replace prof_success_rank_strong = q251_3_rank if prof_success_rank_strong == ""
replace prof_success_group_strongest = q251_4_group if prof_success_group_strongest == ""
replace prof_success_rank_strongest = q251_4_rank if prof_success_rank_strongest == ""
replace prof_success_group_clique = q251_5_group if prof_success_group_clique == ""
replace prof_success_rank_clique = q251_5_rank if prof_success_rank_clique == ""
replace personal_success_group_weakest = q252_1_group if personal_success_group_weakest == ""
replace personal_success_rank_weakest = q252_1_rank if personal_success_rank_weakest == ""
replace personal_success_group_weak = q252_2_group if personal_success_group_weak == ""
replace personal_success_rank_weak = q252_2_rank if personal_success_rank_weak == ""
replace personal_success_group_strong = q252_3_group if personal_success_group_strong == ""
replace personal_success_rank_strong = q252_3_rank if personal_success_rank_strong == ""
replace personal_success_group_strongest = q252_4_group if personal_success_group_strongest == ""
replace personal_success_rank_strongest = q252_4_rank if personal_success_rank_strongest == ""
replace personal_success_group_clique = q252_5_group if personal_success_group_clique == ""
replace personal_success_rank_clique = q252_5_rank if personal_success_rank_clique == ""
replace seat_least_weakest = q253_1_group if seat_least_weakest == ""
replace seat_least_weak = q253_2_group if seat_least_weak == ""
replace drop9 = q253_2_rank if drop9 == ""
replace seat_least_strong = q253_3_group if seat_least_strong == ""
replace drop10 = q253_3_rank if drop10 == ""
replace seat_least_strongest = q253_4_group if seat_least_strongest == ""
replace drop11 = q253_4_rank if drop11 == ""
replace seat_least_clique = q253_5_group if seat_least_clique == ""
replace drop12 = q253_5_rank if drop12 == ""
replace seat_least_you = q253_6_group if seat_least_you == ""
replace drop13 = q253_6_rank if drop13 == ""
replace seat_most_weakest = q254_1_group if seat_most_weakest == ""
replace drop14 = q254_1_rank if drop14 == ""
replace seat_most_weak = q254_2_group if seat_most_weak == ""
replace drop15 = q254_2_rank if drop15 == ""
replace seat_most_strong = q254_3_group if seat_most_strong == ""
replace drop16 = q254_3_rank if drop16 == ""
replace seat_most_strongest = q254_4_group if seat_most_strongest == ""
replace drop17 = q254_4_rank if drop17 == ""
replace seat_most_clique = q254_5_group if seat_most_clique == ""
replace drop18 = q254_5_rank if drop18 == ""
replace seat_most_you = q254_6_group if seat_most_you == ""
replace drop19 = q254_6_rank if drop19 == ""
replace tie_weakest = q257_1 if tie_weakest == ""
replace tie_weak = q257_2 if tie_weak == ""
replace tie_strong = q257_3 if tie_strong == ""
replace tie_strongest = q257_4 if tie_strongest == ""
replace tie_clique = q257_5 if tie_clique == ""
replace drop20 = q265 if drop20 == ""
replace homophily_political = q259 if homophily_political == ""
replace homophily_religious = q260 if homophily_religious == ""
replace homophily_education = q261 if homophily_education == ""
replace homophily_life_skills = q262 if homophily_life_skills == ""
replace game_political = q263 if game_political == ""
replace game_religion = q264 if game_religion == ""
replace jobsearch_weakest = q266_1 if jobsearch_weakest == ""
replace jobsearch_weak = q266_2 if jobsearch_weak == ""
replace jobsearch_strong = q266_3 if jobsearch_strong == ""
replace jobsearch_strongest = q266_4 if jobsearch_strongest == ""
replace jobsearch_clique = q266_5 if jobsearch_clique == ""
replace contribute_weakest = q267_1 if contribute_weakest == ""
replace contribute_weak = q267_2 if contribute_weak == ""
replace contribute_strong = q267_3 if contribute_strong == ""
replace contribute_strongest = q267_4 if contribute_strongest == ""
replace contribute_clique = q267_5 if contribute_clique == ""
replace garner_weakest = q268_1 if garner_weakest == ""
replace garner_weak = q268_2 if garner_weak == ""
replace garner_strong = q268_3 if garner_strong == ""
replace garner_strongest = q268_4 if garner_strongest == ""
replace garner_clique = q268_5 if garner_clique == ""
replace drop22 = q269 if drop22 == ""
replace donate_weakest = q270_1 if donate_weakest == ""
replace donate_weak = q270_2 if donate_weak == ""
replace donate_strong = q270_3 if donate_strong == ""
replace donate_strongest = q270_4 if donate_strongest == ""
replace donate_clique = q270_5 if donate_clique == ""
replace donate_you = q270_6 if donate_you == ""
replace personalgain_weakest = q271_1 if personalgain_weakest == ""
replace personalgain_weak = q271_2 if personalgain_weak == ""
replace personalgain_strong = q271_3 if personalgain_strong == ""
replace personalgain_strongest = q271_4 if personalgain_strongest == ""
replace personalgain_clique = q271_5 if personalgain_clique == ""
replace groupgain_weakest = q272_1 if groupgain_weakest == ""
replace groupgain_weak = q272_2 if groupgain_weak == ""
replace groupgain_strong = q272_3 if groupgain_strong == ""
replace groupgain_strongest = q272_4 if groupgain_strongest == ""
replace groupgain_clique = q272_5 if groupgain_clique == ""
replace peace_weakest = q337 if peace_weakest == ""
replace peace_weakest_join = q338 if peace_weakest_join == ""
replace weak_peace_weakest_inform = q339_2 if weak_peace_weakest_inform == ""
replace strong_peace_weakest_inform = q339_3 if strong_peace_weakest_inform == ""
replace strongest_peace_weakest_inform = q339_4 if strongest_peace_weakest_inform == ""
replace clique_peace_weakest_inform = q339_5 if clique_peace_weakest_inform == ""
replace weak_peace_weakest_prompt = q340_2 if weak_peace_weakest_prompt == ""
replace strong_peace_weakest_prompt = q340_3 if strong_peace_weakest_prompt == ""
replace strongest_peace_weakest_prompt = q340_4 if strongest_peace_weakest_prompt == ""
replace clique_peace_weakest_prompt = q340_5 if clique_peace_weakest_prompt == ""
replace peace_weak = q341 if peace_weak == ""
replace peace_weak_join = q342 if peace_weak_join == ""
replace weakest_peace_weak_inform = q343_2 if weakest_peace_weak_inform == ""
replace strong_peace_weak_inform = q343_3 if strong_peace_weak_inform == ""
replace strongest_peace_weak_inform = q343_4 if strongest_peace_weak_inform == ""
replace clique_peace_weak_inform = q343_5 if clique_peace_weak_inform == ""
replace weakest_peace_weak_prompt = q344_2 if weakest_peace_weak_prompt == ""
replace strong_peace_weak_prompt = q344_3 if strong_peace_weak_prompt == ""
replace strongest_peace_weak_prompt = q344_4 if strongest_peace_weak_prompt == ""
replace clique_peace_weak_prompt = q344_5 if clique_peace_weak_prompt == ""
replace peace_strong = q345 if peace_strong == ""
replace peace_strong_join = q346 if peace_strong_join == ""
replace weakest_peace_strong_inform = q347_2 if weakest_peace_strong_inform == ""
replace weak_peace_strong_inform = q347_3 if weak_peace_strong_inform == ""
replace strongest_peace_strong_inform = q347_4 if strongest_peace_strong_inform == ""
replace clique_peace_strong_inform = q347_5 if clique_peace_strong_inform == ""
replace weakest_peace_strong_prompt = q348_2 if weakest_peace_strong_prompt == ""
replace weak_peace_strong_prompt = q348_3 if weak_peace_strong_prompt == ""
replace strongest_peace_strong_prompt = q348_4 if strongest_peace_strong_prompt == ""
replace clique_peace_strong_prompt = q348_5 if clique_peace_strong_prompt == ""
replace peace_strongest = q349 if peace_strongest == ""
replace peace_strongest_join = q350 if peace_strongest_join == ""
replace weakest_peace_strongest_inform = q351_2 if weakest_peace_strongest_inform == ""
replace weak_peace_strongest_inform = q351_3 if weak_peace_strongest_inform == ""
replace strong_peace_strongest_inform = q351_4 if strong_peace_strongest_inform == ""
replace clique_peace_strongest_inform = q351_5 if clique_peace_strongest_inform == ""
replace weakest_peace_strongest_prompt = q352_2 if weakest_peace_strongest_prompt == ""
replace weak_peace_strongest_prompt = q352_3 if weak_peace_strongest_prompt == ""
replace strong_peace_strongest_prompt = q352_4 if strong_peace_strongest_prompt == ""
replace clique_peace_strongest_prompt = q352_5 if clique_peace_strongest_prompt == ""
replace peace_clique = q353 if peace_clique == ""
replace peace_clique_join = q354 if peace_clique_join == ""
replace weakest_peace_clique_inform = q355_2 if weakest_peace_clique_inform == ""
replace weak_peace_clique_inform = q355_3 if weak_peace_clique_inform == ""
replace strong_peace_clique_inform = q355_4 if strong_peace_clique_inform == ""
replace strongest_peace_clique_inform = q355_5 if strongest_peace_clique_inform == ""
replace weakest_peace_clique_prompt = q356_2 if weakest_peace_clique_prompt == ""
replace weak_peace_clique_prompt = q356_3 if weak_peace_clique_prompt == ""
replace strong_peace_clique_prompt = q356_4 if strong_peace_clique_prompt == ""
replace strongest_peace_clique_prompt = q356_5 if strongest_peace_clique_prompt == ""
replace viol_weakest = q357 if viol_weakest == ""
replace viol_weakest_join = q358 if viol_weakest_join == ""
replace weak_viol_weakest_inform = q359_2 if weak_viol_weakest_inform == ""
replace strong_viol_weakest_inform = q359_3 if strong_viol_weakest_inform == ""
replace strongest_viol_weakest_inform = q359_4 if strongest_viol_weakest_inform == ""
replace clique_viol_weakest_inform = q359_5 if clique_viol_weakest_inform == ""
replace weak_viol_weakest_prompt = q360_2 if weak_viol_weakest_prompt == ""
replace strong_viol_weakest_prompt = q360_3 if strong_viol_weakest_prompt == ""
replace strongest_viol_weakest_prompt = q360_4 if strongest_viol_weakest_prompt == ""
replace clique_viol_weakest_prompt = q360_5 if clique_viol_weakest_prompt == ""
replace viol_weak = q361 if viol_weak == ""
replace viol_weak_join = q362 if viol_weak_join == ""
replace weakest_viol_weak_inform = q363_2 if weakest_viol_weak_inform == ""
replace strong_viol_weak_inform = q363_3 if strong_viol_weak_inform == ""
replace strongest_viol_weak_inform = q363_4 if strongest_viol_weak_inform == ""
replace clique_viol_weak_inform = q363_5 if clique_viol_weak_inform == ""
replace weakest_viol_weak_prompt = q364_2 if weakest_viol_weak_prompt == ""
replace strong_viol_weak_prompt = q364_3 if strong_viol_weak_prompt == ""
replace strongest_viol_weak_prompt = q364_4 if strongest_viol_weak_prompt == ""
replace clique_viol_weak_prompt = q364_5 if clique_viol_weak_prompt == ""
replace viol_strong = q365 if viol_strong == ""
replace viol_strong_join = q366 if viol_strong_join == ""
replace weakest_viol_strong_inform = q367_2 if weakest_viol_strong_inform == ""
replace weak_viol_strong_inform = q367_3 if weak_viol_strong_inform == ""
replace strongest_viol_strong_inform = q367_4 if strongest_viol_strong_inform == ""
replace clique_viol_strong_inform = q367_5 if clique_viol_strong_inform == ""
replace weakest_viol_strong_prompt = q368_2 if weakest_viol_strong_prompt == ""
replace weak_viol_strong_prompt = q368_3 if weak_viol_strong_prompt == ""
replace strongest_viol_strong_prompt = q368_4 if strongest_viol_strong_prompt == ""
replace clique_viol_strong_prompt = q368_5 if clique_viol_strong_prompt == ""
replace viol_strongest = q369 if viol_strongest == ""
replace viol_strongest_join = q370 if viol_strongest_join == ""
replace weakest_viol_strongest_inform = q371_2 if weakest_viol_strongest_inform == ""
replace weak_viol_strongest_inform = q371_3 if weak_viol_strongest_inform == ""
replace strong_viol_strongest_inform = q371_4 if strong_viol_strongest_inform == ""
replace clique_viol_strongest_inform = q371_5 if clique_viol_strongest_inform == ""
replace weakest_viol_strongest_prompt = q372_2 if weakest_viol_strongest_prompt == ""
replace weak_viol_strongest_prompt = q372_3 if weak_viol_strongest_prompt == ""
replace strong_viol_strongest_prompt = q372_4 if strong_viol_strongest_prompt == ""
replace clique_viol_strongest_prompt = q372_5 if clique_viol_strongest_prompt == ""
replace viol_clique = q373 if viol_clique == ""
replace viol_clique_join = q374 if viol_clique_join == ""
replace weakest_viol_clique_inform = q375_2 if weakest_viol_clique_inform == ""
replace weak_viol_clique_inform = q375_3 if weak_viol_clique_inform == ""
replace strong_viol_clique_inform = q375_4 if strong_viol_clique_inform == ""
replace strongest_viol_clique_inform = q375_5 if strongest_viol_clique_inform == ""
replace weakest_viol_clique_prompt = q376_2 if weakest_viol_clique_prompt == ""
replace weak_viol_clique_prompt = q376_3 if weak_viol_clique_prompt == ""
replace strong_viol_clique_prompt = q376_4 if strong_viol_clique_prompt == ""
replace strongest_viol_clique_prompt = q376_5 if strongest_viol_clique_prompt == ""
replace interaction_weakest = q277_1 if interaction_weakest == ""
replace interaction_weak = q277_2 if interaction_weak == ""
replace interaction_strong = q277_3 if interaction_strong == ""
replace interaction_strongest = q277_4 if interaction_strongest == ""
replace interaction_clique = q277_5 if interaction_clique == ""

foreach var of varlist * {
	destring `var', replace
}

g prot_peace = 0
foreach var of varlist peace* {
	replace prot_peace = 1 if `var' != .
}

g prot_invite = "."
replace prot_invite = "weakest" if peace_weakest ~= . | viol_weakest ~= .
replace prot_invite = "weak" if peace_weak ~= . | viol_weak ~= .
replace prot_invite = "strong" if peace_strong ~= . | viol_strong ~= .
replace prot_invite = "strongest" if peace_strongest ~= . | viol_strongest ~= .
replace prot_invite = "clique" if peace_clique ~= . | viol_clique ~= .

g prot_join = 0
foreach var of varlist peace_*_join viol_*_join {
	replace prot_join = 1 if `var' == 1
}

g prot_weakest_inform = .
foreach var of varlist weakest_*_inform {
	replace prot_weakest_inform = 1 if `var' == 1
	replace prot_weakest_inform = -99 if `var' == -99
	replace prot_weakest_inform = 0 if `var' == 0
}

g prot_weakest_prompt = .
foreach var of varlist weakest_*_prompt {
	replace prot_weakest_prompt = 1 if `var' == 1
	replace prot_weakest_prompt = -99 if `var' == -99
	replace prot_weakest_prompt = 0 if `var' == 0
}

g prot_weak_inform = .
foreach var of varlist weak_*_inform {
	replace prot_weak_inform = 1 if `var' == 1
	replace prot_weak_inform = -99 if `var' == -99
	replace prot_weak_inform = 0 if `var' == 0
}

g prot_weak_prompt = .
foreach var of varlist weak_*_prompt {
	replace prot_weak_prompt = 1 if `var' == 1
	replace prot_weak_prompt = -99 if `var' == -99
	replace prot_weak_prompt = 0 if `var' == 0
}

g prot_strong_inform = .
foreach var of varlist strong_*_inform {
	replace prot_strong_inform = 1 if `var' == 1
	replace prot_strong_inform = -99 if `var' == -99
	replace prot_strong_inform = 0 if `var' == 0
}

g prot_strong_prompt = .
foreach var of varlist strong_*_prompt {
	replace prot_strong_prompt = 1 if `var' == 1
	replace prot_strong_prompt = -99 if `var' == -99
	replace prot_strong_prompt = 0 if `var' == 0
}

g prot_strongest_inform = .
foreach var of varlist strongest_*_inform {
	replace prot_strongest_inform = 1 if `var' == 1
	replace prot_strongest_inform = -99 if `var' == -99
	replace prot_strongest_inform = 0 if `var' == 0
}

g prot_strongest_prompt = .
foreach var of varlist strongest_*_prompt {
	replace prot_strongest_prompt = 1 if `var' == 1
	replace prot_strongest_prompt = -99 if `var' == -99
	replace prot_strongest_prompt = 0 if `var' == 0
}

g prot_clique_inform = .
foreach var of varlist clique_*_inform {
	replace prot_clique_inform = 1 if `var' == 1
	replace prot_clique_inform = -99 if `var' == -99
	replace prot_clique_inform = 0 if `var' == 0
}

g prot_clique_prompt = .
foreach var of varlist clique_*_prompt {
	replace prot_clique_prompt = 1 if `var' == 1
	replace prot_clique_prompt = -99 if `var' == -99
	replace prot_clique_prompt = 0 if `var' == 0
}

drop peace* viol*

drop *_viol_* *_peace_*

drop q*

drop doqq*
drop drop*
drop dobr*
drop mturkcode random Disclaimer Instructions
g duration = (clock(v4,"YMD hms")-clock(v3,"YMD hms"))/60000

drop v*

ren *_name name_*
order test* duration dem* intro* online* name_* tie_* homophily_* interaction_* ///
prof_* personal_* jobsearch_* contribute_* garner_* donate_* ///
personalgain_* groupgain_* game_* seat_* prot_*, first

saveold "./bisbee_larson_replication_final/tools/Roll-out-3-14-2015/Thursday/data_clean.dta", replace

********************************************************************************

clear all
insheet using "./bisbee_larson_replication_final/tools/Roll-out-3-14-2015/Sunday/AMT_Test_Qualtrics.csv"

foreach var of varlist * {
  label variable `var' "`=`var'[1]'"
}

drop if _n == 1

ren q284 Disclaimer
ren v9 Instructions
ren q43 online_offline
ren q1 weakest_name
ren q2 weak_name
ren q3 strong_name
ren q4 strongest_name
ren q87 test1
ren q5 clique_name
ren q96 drop5
ren q97_6_group prof_crisis_group_weakest
ren q97_6_rank prof_crisis_rank_weakest
ren q97_7_group prof_crisis_group_weak
ren q97_7_rank prof_crisis_rank_weak
ren q97_8_group prof_crisis_group_strong
ren q97_8_rank prof_crisis_rank_strong
ren q97_9_group prof_crisis_group_strongest
ren q97_9_rank prof_crisis_rank_strongest
ren q97_10_group prof_crisis_group_clique
ren q97_10_rank prof_crisis_rank_clique
ren q47_6_group personal_crisis_group_weakest
ren q47_6_rank personal_crisis_rank_weakest
ren q47_7_group personal_crisis_group_weak
ren q47_7_rank personal_crisis_rank_weak
ren q47_8_group personal_crisis_group_strong
ren q47_8_rank personal_crisis_rank_strong
ren q47_9_group personal_crisis_group_strongest
ren q47_9_rank personal_crisis_rank_strongest
ren q47_10_group personal_crisis_group_clique
ren q47_10_rank personal_crisis_rank_clique
ren q98_1_group prof_success_group_weakest
ren q98_1_rank prof_success_rank_weakest
ren q98_2_group prof_success_group_weak
ren q98_2_rank prof_success_rank_weak
ren q98_3_group prof_success_group_strong
ren q98_3_rank prof_success_rank_strong
ren q98_4_group prof_success_group_strongest
ren q98_4_rank prof_success_rank_strongest
ren q98_5_group prof_success_group_clique
ren q98_5_rank prof_success_rank_clique
ren q48_1_group personal_success_group_weakest
ren q48_1_rank personal_success_rank_weakest
ren q48_2_group personal_success_group_weak
ren q48_2_rank personal_success_rank_weak
ren q48_3_group personal_success_group_strong
ren q48_3_rank personal_success_rank_strong
ren q48_4_group personal_success_group_strongest
ren q48_4_rank personal_success_rank_strongest
ren q48_5_group personal_success_group_clique
ren q48_5_rank personal_success_rank_clique
ren q74 drop6
ren q82 drop7
ren q99_1_group seat_least_weakest
ren q99_1_rank drop8
ren q99_2_group seat_least_weak
ren q99_2_rank drop9
ren q99_3_group seat_least_strong
ren q99_3_rank drop10
ren q99_4_group seat_least_strongest
ren q99_4_rank drop11
ren q99_5_group seat_least_clique
ren q99_5_rank drop12
ren q99_6_group seat_least_you
ren q99_6_rank drop13
ren q100_1_group seat_most_weakest
ren q100_1_rank drop14
ren q100_2_group seat_most_weak
ren q100_2_rank drop15
ren q100_3_group seat_most_strong
ren q100_3_rank drop16
ren q100_4_group seat_most_strongest
ren q100_4_rank drop17
ren q100_5_group seat_most_clique
ren q100_5_rank drop18
ren q100_6_group seat_most_you
ren q100_6_rank drop19
ren q101_1 tie_weakest
ren q101_2 tie_weak
ren q101_3 tie_strong
ren q101_4 tie_strongest
ren q101_5 tie_clique
ren q139 drop20
ren q140 homophily_political
ren q141 homophily_religious
ren q142 homophily_education
ren q143 homophily_life_skills
ren q144 game_political
ren q145 game_religion
ren q150 drop21
ren q151_1 jobsearch_weakest
ren q151_2 jobsearch_weak
ren q151_3 jobsearch_strong
ren q151_4 jobsearch_strongest
ren q151_5 jobsearch_clique
ren q152_1 contribute_weakest
ren q152_2 contribute_weak
ren q152_3 contribute_strong
ren q152_4 contribute_strongest
ren q152_5 contribute_clique
ren q153_1 garner_weakest
ren q153_2 garner_weak
ren q153_3 garner_strong
ren q153_4 garner_strongest
ren q153_5 garner_clique
ren q183 drop22
ren q184_1 donate_weakest
ren q184_2 donate_weak
ren q184_3 donate_strong
ren q184_4 donate_strongest
ren q184_5 donate_clique
ren q184_6 donate_you
ren q185_1 personalgain_weakest
ren q185_2 personalgain_weak
ren q185_3 personalgain_strong
ren q185_4 personalgain_strongest
ren q185_5 personalgain_clique
ren q186_1 groupgain_weakest
ren q186_2 groupgain_weak
ren q186_3 groupgain_strong
ren q186_4 groupgain_strongest
ren q186_5 groupgain_clique
ren q289 peace_weakest
ren q94 peace_weakest_join
ren q95_2 weak_peace_weakest_inform
ren q95_3 strong_peace_weakest_inform
ren q95_4 strongest_peace_weakest_inform
ren q95_5 clique_peace_weakest_inform
ren q128_2 weak_peace_weakest_prompt
ren q128_3 strong_peace_weakest_prompt
ren q128_4 strongest_peace_weakest_prompt
ren q128_5 clique_peace_weakest_prompt
ren q295 peace_weak
ren q296 peace_weak_join
ren q297_2 weakest_peace_weak_inform
ren q297_3 strong_peace_weak_inform
ren q297_4 strongest_peace_weak_inform
ren q297_5 clique_peace_weak_inform
ren q129_2 weakest_peace_weak_prompt
ren q129_3 strong_peace_weak_prompt
ren q129_4 strongest_peace_weak_prompt
ren q129_5 clique_peace_weak_prompt
ren q298 peace_strong
ren q299 peace_strong_join
ren q300_2 weakest_peace_strong_inform
ren q300_3 weak_peace_strong_inform
ren q300_4 strongest_peace_strong_inform
ren q300_5 clique_peace_strong_inform
ren q130_2 weakest_peace_strong_prompt
ren q130_3 weak_peace_strong_prompt
ren q130_4 strongest_peace_strong_prompt
ren q130_5 clique_peace_strong_prompt
ren q301 peace_strongest
ren q302 peace_strongest_join
ren q303_2 weakest_peace_strongest_inform
ren q303_3 weak_peace_strongest_inform
ren q303_4 strong_peace_strongest_inform
ren q303_5 clique_peace_strongest_inform
ren q131_2 weakest_peace_strongest_prompt
ren q131_3 weak_peace_strongest_prompt
ren q131_4 strong_peace_strongest_prompt
ren q131_5 clique_peace_strongest_prompt
ren q304 peace_clique
ren q305 peace_clique_join
ren q306_2 weakest_peace_clique_inform
ren q306_3 weak_peace_clique_inform
ren q306_4 strong_peace_clique_inform
ren q306_5 strongest_peace_clique_inform
ren q132_2 weakest_peace_clique_prompt
ren q132_3 weak_peace_clique_prompt
ren q132_4 strong_peace_clique_prompt
ren q132_5 strongest_peace_clique_prompt
ren q307 viol_weakest
ren q308 viol_weakest_join
ren q309_2 weak_viol_weakest_inform
ren q309_3 strong_viol_weakest_inform
ren q309_4 strongest_viol_weakest_inform
ren q309_5 clique_viol_weakest_inform
ren q133_2 weak_viol_weakest_prompt
ren q133_3 strong_viol_weakest_prompt
ren q133_4 strongest_viol_weakest_prompt
ren q133_5 clique_viol_weakest_prompt
ren q310 viol_weak
ren q311 viol_weak_join
ren q312_2 weakest_viol_weak_inform
ren q312_3 strong_viol_weak_inform
ren q312_4 strongest_viol_weak_inform
ren q312_5 clique_viol_weak_inform
ren q134_2 weakest_viol_weak_prompt
ren q134_3 strong_viol_weak_prompt
ren q134_4 strongest_viol_weak_prompt
ren q134_5 clique_viol_weak_prompt
ren q313 viol_strong
ren q314 viol_strong_join
ren q315_2 weakest_viol_strong_inform
ren q315_3 weak_viol_strong_inform
ren q315_4 strongest_viol_strong_inform
ren q315_5 clique_viol_strong_inform
ren q135_2 weakest_viol_strong_prompt
ren q135_3 weak_viol_strong_prompt
ren q135_4 strongest_viol_strong_prompt
ren q135_5 clique_viol_strong_prompt
ren q316 viol_strongest
ren q317 viol_strongest_join
ren q318_2 weakest_viol_strongest_inform
ren q318_3 weak_viol_strongest_inform
ren q318_4 strong_viol_strongest_inform
ren q318_5 clique_viol_strongest_inform
ren q136_2 weakest_viol_strongest_prompt
ren q136_3 weak_viol_strongest_prompt
ren q136_4 strong_viol_strongest_prompt
ren q136_5 clique_viol_strongest_prompt
ren q319 viol_clique
ren q320 viol_clique_join
ren q321_2 weakest_viol_clique_inform
ren q321_3 weak_viol_clique_inform
ren q321_4 strong_viol_clique_inform
ren q321_5 strongest_viol_clique_inform
ren q137_2 weakest_viol_clique_prompt
ren q137_3 weak_viol_clique_prompt
ren q137_4 strong_viol_clique_prompt
ren q137_5 strongest_viol_clique_prompt
ren q280_1 interaction_weakest
ren q280_2 interaction_weak
ren q280_3 interaction_strong
ren q280_4 interaction_strongest
ren q280_5 interaction_clique
ren q154 drop40
ren q155 dem_educ
ren q156 dem_age
ren q157 dem_industry
ren q158 dem_occupation
ren q159 dem_race
ren q160 dem_country
ren q161 dem_family
ren q162 dem_gender
ren q163 dem_hhinc
ren q164 dem_marital
ren q75_6 intro_q1
ren q75_7 intro_q2
ren q75_8 intro_q3
ren q75_10 intro_q4
ren q75_11 intro_q5
ren q75_12 intro_q6
ren q75_13 intro_q7
ren q75_14 intro_q8
ren q75_15 intro_q9
ren q75_16 test2

g online = 0
replace online = 1 if weakest_name != ""

sort online


replace weakest_name = q239 if weakest_name == ""
replace weak_name = q240 if weak_name == ""
replace strong_name = q241 if strong_name == ""
replace strongest_name = q242 if strongest_name == ""
replace test1 = q88 if test1 == ""
replace clique_name = q243 if clique_name == ""
replace prof_crisis_group_weakest = q249_6_group if prof_crisis_group_weakest == ""
replace prof_crisis_rank_weakest = q249_6_rank if prof_crisis_rank_weakest == ""
replace prof_crisis_group_weak = q249_7_group if prof_crisis_group_weak == ""
replace prof_crisis_rank_weak = q249_7_rank if prof_crisis_rank_weak == ""
replace prof_crisis_group_strong = q249_8_group if prof_crisis_group_strong == ""
replace prof_crisis_rank_strong = q249_8_rank if prof_crisis_rank_strong == ""
replace prof_crisis_group_strongest = q249_9_group if prof_crisis_group_strongest == ""
replace prof_crisis_rank_strongest = q249_9_rank if prof_crisis_rank_strongest == ""
replace prof_crisis_group_clique = q249_10_group if prof_crisis_group_clique == ""
replace prof_crisis_rank_clique = q249_10_rank if prof_crisis_rank_clique == ""
replace personal_crisis_group_weakest = q250_6_group if personal_crisis_group_weakest == ""
replace personal_crisis_rank_weakest = q250_6_rank if personal_crisis_rank_weakest == ""
replace personal_crisis_group_weak = q250_7_group if personal_crisis_group_weak == ""
replace personal_crisis_rank_weak = q250_7_rank if personal_crisis_rank_weak == ""
replace personal_crisis_group_strong = q250_8_group if personal_crisis_group_strong == ""
replace personal_crisis_rank_strong = q250_8_rank if personal_crisis_rank_strong == ""
replace personal_crisis_group_strongest = q250_9_group if personal_crisis_group_strongest == ""
replace personal_crisis_rank_strongest = q250_9_rank if personal_crisis_rank_strongest == ""
replace personal_crisis_group_clique = q250_10_group if personal_crisis_group_clique == ""
replace personal_crisis_rank_clique = q250_10_rank if personal_crisis_rank_clique == ""
replace prof_success_group_weakest = q251_1_group if prof_success_group_weakest == ""
replace prof_success_rank_weakest = q251_1_rank if prof_success_rank_weakest == ""
replace prof_success_group_weak = q251_2_group if prof_success_group_weak == ""
replace prof_success_rank_weak = q251_2_rank if prof_success_rank_weak == ""
replace prof_success_group_strong = q251_3_group if prof_success_group_strong == ""
replace prof_success_rank_strong = q251_3_rank if prof_success_rank_strong == ""
replace prof_success_group_strongest = q251_4_group if prof_success_group_strongest == ""
replace prof_success_rank_strongest = q251_4_rank if prof_success_rank_strongest == ""
replace prof_success_group_clique = q251_5_group if prof_success_group_clique == ""
replace prof_success_rank_clique = q251_5_rank if prof_success_rank_clique == ""
replace personal_success_group_weakest = q252_1_group if personal_success_group_weakest == ""
replace personal_success_rank_weakest = q252_1_rank if personal_success_rank_weakest == ""
replace personal_success_group_weak = q252_2_group if personal_success_group_weak == ""
replace personal_success_rank_weak = q252_2_rank if personal_success_rank_weak == ""
replace personal_success_group_strong = q252_3_group if personal_success_group_strong == ""
replace personal_success_rank_strong = q252_3_rank if personal_success_rank_strong == ""
replace personal_success_group_strongest = q252_4_group if personal_success_group_strongest == ""
replace personal_success_rank_strongest = q252_4_rank if personal_success_rank_strongest == ""
replace personal_success_group_clique = q252_5_group if personal_success_group_clique == ""
replace personal_success_rank_clique = q252_5_rank if personal_success_rank_clique == ""
replace seat_least_weakest = q253_1_group if seat_least_weakest == ""
replace seat_least_weak = q253_2_group if seat_least_weak == ""
replace drop9 = q253_2_rank if drop9 == ""
replace seat_least_strong = q253_3_group if seat_least_strong == ""
replace drop10 = q253_3_rank if drop10 == ""
replace seat_least_strongest = q253_4_group if seat_least_strongest == ""
replace drop11 = q253_4_rank if drop11 == ""
replace seat_least_clique = q253_5_group if seat_least_clique == ""
replace drop12 = q253_5_rank if drop12 == ""
replace seat_least_you = q253_6_group if seat_least_you == ""
replace drop13 = q253_6_rank if drop13 == ""
replace seat_most_weakest = q254_1_group if seat_most_weakest == ""
replace drop14 = q254_1_rank if drop14 == ""
replace seat_most_weak = q254_2_group if seat_most_weak == ""
replace drop15 = q254_2_rank if drop15 == ""
replace seat_most_strong = q254_3_group if seat_most_strong == ""
replace drop16 = q254_3_rank if drop16 == ""
replace seat_most_strongest = q254_4_group if seat_most_strongest == ""
replace drop17 = q254_4_rank if drop17 == ""
replace seat_most_clique = q254_5_group if seat_most_clique == ""
replace drop18 = q254_5_rank if drop18 == ""
replace seat_most_you = q254_6_group if seat_most_you == ""
replace drop19 = q254_6_rank if drop19 == ""
replace tie_weakest = q257_1 if tie_weakest == ""
replace tie_weak = q257_2 if tie_weak == ""
replace tie_strong = q257_3 if tie_strong == ""
replace tie_strongest = q257_4 if tie_strongest == ""
replace tie_clique = q257_5 if tie_clique == ""
replace drop20 = q265 if drop20 == ""
replace homophily_political = q259 if homophily_political == ""
replace homophily_religious = q260 if homophily_religious == ""
replace homophily_education = q261 if homophily_education == ""
replace homophily_life_skills = q262 if homophily_life_skills == ""
replace game_political = q263 if game_political == ""
replace game_religion = q264 if game_religion == ""
replace jobsearch_weakest = q266_1 if jobsearch_weakest == ""
replace jobsearch_weak = q266_2 if jobsearch_weak == ""
replace jobsearch_strong = q266_3 if jobsearch_strong == ""
replace jobsearch_strongest = q266_4 if jobsearch_strongest == ""
replace jobsearch_clique = q266_5 if jobsearch_clique == ""
replace contribute_weakest = q267_1 if contribute_weakest == ""
replace contribute_weak = q267_2 if contribute_weak == ""
replace contribute_strong = q267_3 if contribute_strong == ""
replace contribute_strongest = q267_4 if contribute_strongest == ""
replace contribute_clique = q267_5 if contribute_clique == ""
replace garner_weakest = q268_1 if garner_weakest == ""
replace garner_weak = q268_2 if garner_weak == ""
replace garner_strong = q268_3 if garner_strong == ""
replace garner_strongest = q268_4 if garner_strongest == ""
replace garner_clique = q268_5 if garner_clique == ""
replace drop22 = q269 if drop22 == ""
replace donate_weakest = q270_1 if donate_weakest == ""
replace donate_weak = q270_2 if donate_weak == ""
replace donate_strong = q270_3 if donate_strong == ""
replace donate_strongest = q270_4 if donate_strongest == ""
replace donate_clique = q270_5 if donate_clique == ""
replace donate_you = q270_6 if donate_you == ""
replace personalgain_weakest = q271_1 if personalgain_weakest == ""
replace personalgain_weak = q271_2 if personalgain_weak == ""
replace personalgain_strong = q271_3 if personalgain_strong == ""
replace personalgain_strongest = q271_4 if personalgain_strongest == ""
replace personalgain_clique = q271_5 if personalgain_clique == ""
replace groupgain_weakest = q272_1 if groupgain_weakest == ""
replace groupgain_weak = q272_2 if groupgain_weak == ""
replace groupgain_strong = q272_3 if groupgain_strong == ""
replace groupgain_strongest = q272_4 if groupgain_strongest == ""
replace groupgain_clique = q272_5 if groupgain_clique == ""
replace peace_weakest = q337 if peace_weakest == ""
replace peace_weakest_join = q338 if peace_weakest_join == ""
replace weak_peace_weakest_inform = q339_2 if weak_peace_weakest_inform == ""
replace strong_peace_weakest_inform = q339_3 if strong_peace_weakest_inform == ""
replace strongest_peace_weakest_inform = q339_4 if strongest_peace_weakest_inform == ""
replace clique_peace_weakest_inform = q339_5 if clique_peace_weakest_inform == ""
replace weak_peace_weakest_prompt = q340_2 if weak_peace_weakest_prompt == ""
replace strong_peace_weakest_prompt = q340_3 if strong_peace_weakest_prompt == ""
replace strongest_peace_weakest_prompt = q340_4 if strongest_peace_weakest_prompt == ""
replace clique_peace_weakest_prompt = q340_5 if clique_peace_weakest_prompt == ""
replace peace_weak = q341 if peace_weak == ""
replace peace_weak_join = q342 if peace_weak_join == ""
replace weakest_peace_weak_inform = q343_2 if weakest_peace_weak_inform == ""
replace strong_peace_weak_inform = q343_3 if strong_peace_weak_inform == ""
replace strongest_peace_weak_inform = q343_4 if strongest_peace_weak_inform == ""
replace clique_peace_weak_inform = q343_5 if clique_peace_weak_inform == ""
replace weakest_peace_weak_prompt = q344_2 if weakest_peace_weak_prompt == ""
replace strong_peace_weak_prompt = q344_3 if strong_peace_weak_prompt == ""
replace strongest_peace_weak_prompt = q344_4 if strongest_peace_weak_prompt == ""
replace clique_peace_weak_prompt = q344_5 if clique_peace_weak_prompt == ""
replace peace_strong = q345 if peace_strong == ""
replace peace_strong_join = q346 if peace_strong_join == ""
replace weakest_peace_strong_inform = q347_2 if weakest_peace_strong_inform == ""
replace weak_peace_strong_inform = q347_3 if weak_peace_strong_inform == ""
replace strongest_peace_strong_inform = q347_4 if strongest_peace_strong_inform == ""
replace clique_peace_strong_inform = q347_5 if clique_peace_strong_inform == ""
replace weakest_peace_strong_prompt = q348_2 if weakest_peace_strong_prompt == ""
replace weak_peace_strong_prompt = q348_3 if weak_peace_strong_prompt == ""
replace strongest_peace_strong_prompt = q348_4 if strongest_peace_strong_prompt == ""
replace clique_peace_strong_prompt = q348_5 if clique_peace_strong_prompt == ""
replace peace_strongest = q349 if peace_strongest == ""
replace peace_strongest_join = q350 if peace_strongest_join == ""
replace weakest_peace_strongest_inform = q351_2 if weakest_peace_strongest_inform == ""
replace weak_peace_strongest_inform = q351_3 if weak_peace_strongest_inform == ""
replace strong_peace_strongest_inform = q351_4 if strong_peace_strongest_inform == ""
replace clique_peace_strongest_inform = q351_5 if clique_peace_strongest_inform == ""
replace weakest_peace_strongest_prompt = q352_2 if weakest_peace_strongest_prompt == ""
replace weak_peace_strongest_prompt = q352_3 if weak_peace_strongest_prompt == ""
replace strong_peace_strongest_prompt = q352_4 if strong_peace_strongest_prompt == ""
replace clique_peace_strongest_prompt = q352_5 if clique_peace_strongest_prompt == ""
replace peace_clique = q353 if peace_clique == ""
replace peace_clique_join = q354 if peace_clique_join == ""
replace weakest_peace_clique_inform = q355_2 if weakest_peace_clique_inform == ""
replace weak_peace_clique_inform = q355_3 if weak_peace_clique_inform == ""
replace strong_peace_clique_inform = q355_4 if strong_peace_clique_inform == ""
replace strongest_peace_clique_inform = q355_5 if strongest_peace_clique_inform == ""
replace weakest_peace_clique_prompt = q356_2 if weakest_peace_clique_prompt == ""
replace weak_peace_clique_prompt = q356_3 if weak_peace_clique_prompt == ""
replace strong_peace_clique_prompt = q356_4 if strong_peace_clique_prompt == ""
replace strongest_peace_clique_prompt = q356_5 if strongest_peace_clique_prompt == ""
replace viol_weakest = q357 if viol_weakest == ""
replace viol_weakest_join = q358 if viol_weakest_join == ""
replace weak_viol_weakest_inform = q359_2 if weak_viol_weakest_inform == ""
replace strong_viol_weakest_inform = q359_3 if strong_viol_weakest_inform == ""
replace strongest_viol_weakest_inform = q359_4 if strongest_viol_weakest_inform == ""
replace clique_viol_weakest_inform = q359_5 if clique_viol_weakest_inform == ""
replace weak_viol_weakest_prompt = q360_2 if weak_viol_weakest_prompt == ""
replace strong_viol_weakest_prompt = q360_3 if strong_viol_weakest_prompt == ""
replace strongest_viol_weakest_prompt = q360_4 if strongest_viol_weakest_prompt == ""
replace clique_viol_weakest_prompt = q360_5 if clique_viol_weakest_prompt == ""
replace viol_weak = q361 if viol_weak == ""
replace viol_weak_join = q362 if viol_weak_join == ""
replace weakest_viol_weak_inform = q363_2 if weakest_viol_weak_inform == ""
replace strong_viol_weak_inform = q363_3 if strong_viol_weak_inform == ""
replace strongest_viol_weak_inform = q363_4 if strongest_viol_weak_inform == ""
replace clique_viol_weak_inform = q363_5 if clique_viol_weak_inform == ""
replace weakest_viol_weak_prompt = q364_2 if weakest_viol_weak_prompt == ""
replace strong_viol_weak_prompt = q364_3 if strong_viol_weak_prompt == ""
replace strongest_viol_weak_prompt = q364_4 if strongest_viol_weak_prompt == ""
replace clique_viol_weak_prompt = q364_5 if clique_viol_weak_prompt == ""
replace viol_strong = q365 if viol_strong == ""
replace viol_strong_join = q366 if viol_strong_join == ""
replace weakest_viol_strong_inform = q367_2 if weakest_viol_strong_inform == ""
replace weak_viol_strong_inform = q367_3 if weak_viol_strong_inform == ""
replace strongest_viol_strong_inform = q367_4 if strongest_viol_strong_inform == ""
replace clique_viol_strong_inform = q367_5 if clique_viol_strong_inform == ""
replace weakest_viol_strong_prompt = q368_2 if weakest_viol_strong_prompt == ""
replace weak_viol_strong_prompt = q368_3 if weak_viol_strong_prompt == ""
replace strongest_viol_strong_prompt = q368_4 if strongest_viol_strong_prompt == ""
replace clique_viol_strong_prompt = q368_5 if clique_viol_strong_prompt == ""
replace viol_strongest = q369 if viol_strongest == ""
replace viol_strongest_join = q370 if viol_strongest_join == ""
replace weakest_viol_strongest_inform = q371_2 if weakest_viol_strongest_inform == ""
replace weak_viol_strongest_inform = q371_3 if weak_viol_strongest_inform == ""
replace strong_viol_strongest_inform = q371_4 if strong_viol_strongest_inform == ""
replace clique_viol_strongest_inform = q371_5 if clique_viol_strongest_inform == ""
replace weakest_viol_strongest_prompt = q372_2 if weakest_viol_strongest_prompt == ""
replace weak_viol_strongest_prompt = q372_3 if weak_viol_strongest_prompt == ""
replace strong_viol_strongest_prompt = q372_4 if strong_viol_strongest_prompt == ""
replace clique_viol_strongest_prompt = q372_5 if clique_viol_strongest_prompt == ""
replace viol_clique = q373 if viol_clique == ""
replace viol_clique_join = q374 if viol_clique_join == ""
replace weakest_viol_clique_inform = q375_2 if weakest_viol_clique_inform == ""
replace weak_viol_clique_inform = q375_3 if weak_viol_clique_inform == ""
replace strong_viol_clique_inform = q375_4 if strong_viol_clique_inform == ""
replace strongest_viol_clique_inform = q375_5 if strongest_viol_clique_inform == ""
replace weakest_viol_clique_prompt = q376_2 if weakest_viol_clique_prompt == ""
replace weak_viol_clique_prompt = q376_3 if weak_viol_clique_prompt == ""
replace strong_viol_clique_prompt = q376_4 if strong_viol_clique_prompt == ""
replace strongest_viol_clique_prompt = q376_5 if strongest_viol_clique_prompt == ""
replace interaction_weakest = q277_1 if interaction_weakest == ""
replace interaction_weak = q277_2 if interaction_weak == ""
replace interaction_strong = q277_3 if interaction_strong == ""
replace interaction_strongest = q277_4 if interaction_strongest == ""
replace interaction_clique = q277_5 if interaction_clique == ""

foreach var of varlist * {
	destring `var', replace
}

g prot_peace = 0
foreach var of varlist peace* {
	replace prot_peace = 1 if `var' != .
}

g prot_invite = "."
replace prot_invite = "weakest" if peace_weakest ~= . | viol_weakest ~= .
replace prot_invite = "weak" if peace_weak ~= . | viol_weak ~= .
replace prot_invite = "strong" if peace_strong ~= . | viol_strong ~= .
replace prot_invite = "strongest" if peace_strongest ~= . | viol_strongest ~= .
replace prot_invite = "clique" if peace_clique ~= . | viol_clique ~= .

g prot_join = 0
foreach var of varlist peace_*_join viol_*_join {
	replace prot_join = 1 if `var' == 1
}

g prot_weakest_inform = .
foreach var of varlist weakest_*_inform {
	replace prot_weakest_inform = 1 if `var' == 1
	replace prot_weakest_inform = -99 if `var' == -99
	replace prot_weakest_inform = 0 if `var' == 0
}

g prot_weakest_prompt = .
foreach var of varlist weakest_*_prompt {
	replace prot_weakest_prompt = 1 if `var' == 1
	replace prot_weakest_prompt = -99 if `var' == -99
	replace prot_weakest_prompt = 0 if `var' == 0
}

g prot_weak_inform = .
foreach var of varlist weak_*_inform {
	replace prot_weak_inform = 1 if `var' == 1
	replace prot_weak_inform = -99 if `var' == -99
	replace prot_weak_inform = 0 if `var' == 0
}

g prot_weak_prompt = .
foreach var of varlist weak_*_prompt {
	replace prot_weak_prompt = 1 if `var' == 1
	replace prot_weak_prompt = -99 if `var' == -99
	replace prot_weak_prompt = 0 if `var' == 0
}

g prot_strong_inform = .
foreach var of varlist strong_*_inform {
	replace prot_strong_inform = 1 if `var' == 1
	replace prot_strong_inform = -99 if `var' == -99
	replace prot_strong_inform = 0 if `var' == 0
}

g prot_strong_prompt = .
foreach var of varlist strong_*_prompt {
	replace prot_strong_prompt = 1 if `var' == 1
	replace prot_strong_prompt = -99 if `var' == -99
	replace prot_strong_prompt = 0 if `var' == 0
}

g prot_strongest_inform = .
foreach var of varlist strongest_*_inform {
	replace prot_strongest_inform = 1 if `var' == 1
	replace prot_strongest_inform = -99 if `var' == -99
	replace prot_strongest_inform = 0 if `var' == 0
}

g prot_strongest_prompt = .
foreach var of varlist strongest_*_prompt {
	replace prot_strongest_prompt = 1 if `var' == 1
	replace prot_strongest_prompt = -99 if `var' == -99
	replace prot_strongest_prompt = 0 if `var' == 0
}

g prot_clique_inform = .
foreach var of varlist clique_*_inform {
	replace prot_clique_inform = 1 if `var' == 1
	replace prot_clique_inform = -99 if `var' == -99
	replace prot_clique_inform = 0 if `var' == 0
}

g prot_clique_prompt = .
foreach var of varlist clique_*_prompt {
	replace prot_clique_prompt = 1 if `var' == 1
	replace prot_clique_prompt = -99 if `var' == -99
	replace prot_clique_prompt = 0 if `var' == 0
}

drop peace* viol*

drop *_viol_* *_peace_*

drop q*

drop doqq*
drop drop*
drop dobr*
drop mturkcode random Disclaimer Instructions
g duration = (clock(v4,"MDY hm")-clock(v3,"MDY hm"))/60000

drop v*

ren *_name name_*
order test* duration dem* intro* online* name_* tie_* homophily_* interaction_* ///
prof_* personal_* jobsearch_* contribute_* garner_* donate_* ///
personalgain_* groupgain_* game_* seat_* prot_*, first

saveold "./bisbee_larson_replication_final/tools/Roll-out-3-14-2015/Sunday/data_clean.dta", replace

********************************************************************************

use "./bisbee_larson_replication_final/tools/Roll-out-3-14-2015/Thursday/data_clean.dta", clear
append using "./bisbee_larson_replication_final/tools/Roll-out-3-14-2015/Sunday/data_clean.dta"

********************************************************************************

foreach var of varlist * {
	local vartype: type `var'
	if substr("`vartype'",1,3)!="str" {
	replace `var' = . if `var' == -99
	}
}

ren *crisis* *cris*
ren *success* *succ*
ren *group* *grp*
ren *rank* *rnk*
ren personal_* pers_*
foreach var of varlist prof* {
	local name = substr("`var'",1,9)
	di "`name'"
	local type = substr("`var'",15,10)
	di "`type'"
	capture g `name'_synth_`type' = (1-`name'_grp_`type')*`name'_rnk_`type'
}

foreach var of varlist pers_* {
	local name = substr("`var'",1,9)
	di "`name'"
	local type = substr("`var'",15,10)
	di "`type'"
	capture g `name'_synth_`type' = (1-`name'_grp_`type')*`name'_rnk_`type'
}

foreach var of varlist tie_* personalgain_* {
	g `var'_synth = .
	replace `var'_synth = 10 if `var' == 1
	replace `var'_synth = 5 if `var' == 2
	replace `var'_synth = 0 if `var' == 3
	replace `var'_synth = -5 if `var' == 4
	replace `var'_synth = -10 if `var' == 5
}

ren *least* *lst*
ren *most* *mst*
foreach var of varlist seat_* {
	local type = substr("`var'",10,10)
	di "`type'"
	if "`type'" != "you" {
	local name = substr("`var'",1,8)
	di "`name'"
	capture drop `var'_synth
	g `var'_synth = .
	replace `var'_synth = 5 if abs(`var'-`name'_you)==3
	replace `var'_synth = 2 if (`name'_you == 0 & `var' == 1) | (`name'_you == 1 & (`var' == 0 | `var'==2)) ///
		| (`name'_you == 2 & `var' == 1) | (`name'_you == 3 & `var' == 4) | (`name'_you == 4 & (`var' == 3 | `var' == 5)) ///
		| (`name'_you == 5 & `var' == 4)
	replace `var'_synth = -2 if (`name'_you == 0 & (`var' == 5 | `var' == 2)) | (`name'_you == 5 & (`var' == 0 | `var' == 3)) ///
		| (`name'_you == 2 & (`var' == 3 | `var' == 0)) | (`name'_you == 3 & (`var' == 2 | `var' == 5))
	replace `var'_synth = 0 if  (`name'_you == 0 & `var' == 4) | (`name'_you == 1 & (`var' == 3 | `var' == 5)) ///
		| (`name'_you == 2 & `var' == 4) | (`name'_you == 3 & `var' == 1) | (`name'_you == 4 & (`var' == 0 | `var' == 2)) ///
		| (`name'_you == 5 & `var' == 1)
	g `var'_synth2 = .
	replace `var'_synth2 = -5 if abs(`var'-`name'_you)==3
	replace `var'_synth2 = -2 if (`name'_you == 0 & `var'==1) | (`name'_you == 1 & (`var' == 0 | `var' == 2)) ///
		| (`name'_you == 2 & `var' == 1) | (`name'_you == 3 & `var'==4) | (`name'_you == 4 & (`var'==3|`var'==5)) ///
		| (`name'_you == 5 & `var' == 4)
	replace `var'_synth2 = 2 if (`name'_you == 0 & (`var' == 5 | `var' == 2)) | (`name'_you == 5 & (`var' == 0 | `var' == 3)) ///
		| (`name'_you == 2 & (`var' == 3 | `var' == 0)) | (`name'_you == 3 & (`var' == 2 | `var' == 5))
	replace `var'_synth2 = 0 if  (`name'_you == 0 & `var' == 4) | (`name'_you == 1 & (`var' == 3 | `var' == 5)) ///
		| (`name'_you == 2 & `var' == 4) | (`name'_you == 3 & `var' == 1) | (`name'_you == 4 & (`var' == 0 | `var' == 2)) ///
		| (`name'_you == 5 & `var' == 1)
	}
	if "`name'" == "seat_mst" {
	g `var'_connected1 = 0
	replace `var'_connected1 = 1 if (`var' == 1 | `var' == 4)
	}
	if "`name'" == "seat_lst" {
	g `var'_connected2 = 0
	replace `var'_connected2 = 1 if (`var' == 0 | `var' == 2 | `var' == 3 | `var' == 5)
	}
}

foreach var of varlist homophily* {
	capture drop `var'_dummy*
	tabulate `var', g(`var'_dummy)
	ren `var'_dummy1 `var'_weakest
	ren `var'_dummy2 `var'_weak
	ren `var'_dummy3 `var'_strong
	ren `var'_dummy4 `var'_strongest
	ren `var'_dummy5 `var'_clique
}

g introvert = intro_q1 + intro_q2 + intro_q3 + intro_q4 + intro_q5 + intro_q6 + intro_q7 + intro_q8 + intro_q9

**** Labeling everything
label define educlab 2 "Preschool" 3 "Kindergarten" 4 "Grade 1-4" 5 "Grade 5-8" 6 "Grade 9-12" 7 "College" 8 "Graduate"
label list educlab
label val dem_educ educlab
tab dem_educ

g dem_educ_low = 0
replace dem_educ_low = 1 if dem_educ <= 6

g dem_educ_high = 0
replace dem_educ_high = 1 if dem_educ_low == 0

label define agelab 1 "<15" 2 "15-24" 3 "25-34" 4 "35-44" 5 "45-54" 6 "55-64" 7 "65+"
label val dem_age agelab
tab dem_age

g dem_ya = 0
replace dem_ya = 1 if dem_age <= 2

g dem_adult = 0
replace dem_adult = 1 if dem_ya == 0

label define indlab 1 "Forestry, fishing, hunting or agriculture support" 2 "Mining" 3 "Utilities" 4 "Construction" 5 "Manufacturing" 6 "Wholesale trade" 7 "Retail trade" 8 "Transportation or warehousing" 9 "Information" 10 "Finance or insurance" 11 "Real estate or rental and leasing" 12 "Professional, scientific or technical services" 13 "Management of companies or enterprises" 14 "Admin, support, waste management or remediation services" 15 "Educational services" 16 "Health care or social assistance" 17 "Arts, entertainment or recreation" 18 "Accommodation or food services" 19 "Other services (except public administration)" 20 "Unclassified establishments"
label val dem_industry indlab
tab dem_industry

label define occlab 1 "Management, professional, and related" 2 "Service" 3 "Sales and office" 4 "Farming, fishing, and forestry" 5 "Construction, extraction, and maintenance" 6 "Production, transportation, and material moving" 7 "Government" 8 "Retired" 9 "Unemployed" 10 "Other"
label val dem_occupation occlab
tab dem_occupation

label define racelab 1 "White/Caucasian" 2 "African American" 3 "Hispanic" 4 "Asian" 5 "Native American" 6 "Pacific Islander" 7 "Other"
label val dem_race racelab
tab dem_race

label define cntrylab 1 "Please select below..." 2 "Afghanistan" 3 "Albania" 4 "Algeria" 5 "Andorra" 6 "Angola" 7 "Antigua and Barbuda" 8 "Argentina" 9 "Armenia" 10 "Australia" 11 "Austria" 12 "Azerbaijan" 13 "Bahamas" 14 "Bahrain" 15 "Bangladesh" 16 "Barbados" 17 "Belarus" 18 "Belgium" 19 "Belize" 20 "Benin" 21 "Bhutan" 22 "Bolivia" 23 "Bosnia and Herzegovina" 24 "Botswana" 25 "Brazil" 26 "Brunei" 27 "Bulgaria" 28 "Burkina Faso" 29 "Burma/Myanmar" 30 "Burundi" 31 "Cambodia" 32 "Cameroon" 33 "Canada" 34 "Cape Verde" 35 "Central African Republic" 36 "Chad" 37 "Chile" 38 "China" 39 "Colombia" 40 "Comoros" 41 "Congo" 42 "Congo, Democratic Republic of" 43 "Costa Rica" 44 "Cote d'Ivoire/Ivory Coast" 45 "Croatia" 46 "Cuba" 47 "Cyprus" 48 "Czech Republic" 49 "Denmark" 50 "Djibouti" 51 "Dominica" 52 "Dominican Republic" 53 "East Timor" 54 "Ecuador" 55 "Egypt" 56 "El Salvador" 57 "Equatorial Guinea" 58 "Eritrea" 59 "Estonia" 60 "Ethiopia Fiji" 61 "Finland" 62 "France" 63 "Gabon" 64 "Gambia" 65 "Georgia" 66 "Germany" 67 "Ghana" 68 "Greece" 69 "Grenada" 70 "Guatemala" 71 "Guinea" 72 "Guinea-Bissau (Bissau) (AF)" 73 "Guyana" 74 "Haiti" 75 "Honduras" 76 "Hungary" 77 "Iceland" 78 "India" 79 "Indonesia" 80 "Iran" 81 "Iraq" 82 "Ireland" 83 "Israel" 84 "Italy" 85 "Jamaica" 86 "Japan" 87 "Jordan" 88 "Kazakstan" 89 "Kenya" 90 "Kiribati" 91 "Korea, North" 92 "Korea, South" 93 "Kuwait" 94 "Kyrgyzstan" 95 "Laos" 96 "Latvia" 97 "Lebanon" 98 "Lesotho" 99 "Liberia" 100 "Libya" 101 "Liechtenstein" 102 "Lithuania" 103 "Luxembourg" 104 "Macedonia" 105 "Madagascar" 106 "Malawi" 107 "Malaysia" 108 "Maldives" 109 "Mali" 110 "Malta" 111 "Marshall Islands" 112 "Mauritania" 113 "Mauritius" 114 "Mexico" 115 "Micronesia" 116 "Moldova" 117 "Monaco" 118 "Mongolia" 119 "Montenegro" 120 "Morocco" 121 "Mozambique" 122 "Namibia" 123 "Nauru" 124 "Nepal" 125 "Netherlands" 126 "New Zealand" 127 "Nicaragua" 128 "Niger" 129 "Nigeria" 130 "Norway" 131 "Oman" 132 "Pakistan" 133 "Palau" 134 "Panama" 135 "Papua New Guinea" 136 "Paraguay" 137 "Peru" 138 "Philippines" 139 "Poland" 140 "Portugal" 141 "Qatar" 142 "Romania" 143 "Russian Federation" 144 "Rwanda" 145 "Saint Kitts and Nevis" 146 "Saint Lucia" 147 "Saint Vincent and the Grenadines" 148 "Samoa" 149 "San Marino" 150 "Sao Tome and Principe" 151 "Saudi Arabia" 152 "Senegal" 153 "Serbia" 154 "Seychelles" 155 "Sierra Leone" 156 "Singapore" 157 "Slovakia" 158 "Slovenia" 159 "Solomon Islands" 160 "Somalia" 161 "South Africa" 162 "Spain" 163 "Sri Lanka" 164 "Sudan" 165 "Suriname" 166 "Swaziland" 167 "Sweden" 168 "Switzerland" 169 "Syria" 170 "Taiwan" 171 "Tajikistan" 172 "Tanzania" 173 "Thailand" 174 "Togo" 175 "Tonga" 176 "Trinidad and Tobago" 177 "Tunisia" 178 "Turkey" 179 "Turkmenistan" 180 "Tuvalu" 181 "Uganda" 182 "Ukraine" 183 "United Arab Emirates" 184 "United Kingdom" 185 "United States" 186 "Uruguay" 187 "Uzbekistan" 188 "Vanuatu" 189 "Vatican City" 190 "Venezuela" 191 "Vietnam" 192 "Yemen" 193 "Zambia" 194 "Zimbabwe" 195 "Other"
label val dem_country cntrylab
tab dem_country 

g dem_US = 0
replace dem_US = 1 if dem_country == 185

g dem_foreign = 0
replace dem_foreign = 1 if dem_US == 0

label define famlab 1 "In a married-couple family" 2 "In a family with female householder, no spouse present" 3 "In a family with male householder, no spouse present" 4 "In a group of unrelated subfamilies" 5 "Unrelated individuals"
label val dem_family famlab
tab dem_family

g dem_fam_mar = 0
replace dem_fam_mar = 1 if dem_family == 1

g dem_fam_sing = 0
replace dem_fam_sing = 1 if dem_family == 2 | dem_family == 3

g dem_fam_unr = 0
replace dem_fam_unr = 1 if dem_fam_mar == 0 & dem_fam_sing == 0

label define genderlab 1 "Male" 2 "Female"
label val dem_gender genderlab
tab dem_gender

label define inclab 1 "under $20,000" 2 "20,000-29,999" 3 "30,000-39,999" 4 "40,000-49,999" 5 "50,000-59,999" 6 "60,000-69,999" 7 "70,000-79,999" 8 "80,000-89,999" 9 "90,000-99,999" 10 "100,000-109,999" 11 "110,000-119,999" 12 "120,000-129,999" 13 "130,000-139,999" 14 "140,000-149,999" 15 "150,000+"
label val dem_hhinc inclab
tab dem_hhinc

label define maritlab 1 "Single, never married" 2 "Married without children" 3 "Married with children" 4 "Divorced" 5 "Seperated" 6 "Widowed" 7 "Living w/ partner"
label val dem_marital maritlab
tab dem_marital

*** Dropping test fails and those that took it too fast
g attention = 0
replace attention = 1 if test1 ~= 8 | test2 ~= 5
sum attention

g time = 0
replace time = 1 if duration < 7

sum time

saveold "./bisbee_larson_replication_final/tools/data_prepped.dta", replace
use "./bisbee_larson_replication_final/tools/data_prepped.dta", clear
drop if test1 ~= 8
drop if test2 ~= 5
drop if duration < 7

drop online_offline name_* test*

foreach var of varlist prof_* pers_* {
	replace `var' = 10 if `var' == 0
}
foreach var of varlist jobsearch_* interaction_* contribute_* garner_* personalgain_* grpgain_* prof_* pers_* {
	replace `var' = -1*`var'
}

// Basic renames
ren dem_educ_* dem2_educ_*
ren dem_ya dem2_ya
ren dem_adult dem2_adult
ren dem_US dem2_US
ren dem_foreign dem2_foreign
ren dem_fam_* dem2_fam_*

foreach var of varlist dem_* {
	drop if `var' == .
	tab `var', g(dum_`var')
	ren dum_`var'1 dropdum_`var'1
}
ren homophily_* homo_*
ren *_religious_* *_rel_*
ren *_political_* *_pol_*
ren *_education_* *_educ_*
ren *_life_skills_* *_ls_*

ren tie_*_synth tie_synth_*
ren seat_*_synth seat_synth_*
ren seat_*_synth2 seat_synth2_*
ren seat_*_connected1 seat_connected1_*
ren personalgain_*_synth synth_personalgain_*

foreach var of varlist jobsearch* contribute* garner* donate* personalgain* grpgain* homo_* tie_* pers_*_synth_* prof_*_synth_* seat_synth2_* interaction* {
	sum `var'
	g std_`var' = (`var' - r(mean))/r(sd)
}

cem dem2_educ_low dem2_educ_high dem2_ya dem2_adult dem_race dem2_US dem2_foreign dem2_fam_mar dem2_fam_sing dem2_fam_unr dem_hhinc (#2) introvert (#2), treatment(online)
egen strata = group(dem_*)

ssc install chaidforest
chaidforest online, unordered(dem2_educ_low dem2_educ_high dem2_ya dem2_adult ///
						dem_race dem_gender dem2_US dem2_foreign dem2_fam_mar ///
						dem2_fam_sing dem2_fam_unr dem_hhinc introvert)
predict onlinehat
g ipwbart = online + (1-online)/(1-onlinehat1)

ren prot_*_inform prot_inform_*
ren prot_*_prompt prot_prompt_*

saveold "./bisbee_larson_replication_final/tools/final_data_clean.dta", replace

use "./bisbee_larson_replication_final/tools/final_data_clean.dta", clear
g ind = _n
keep std_* online introvert ind
drop std_homo_political std_homo_religious std_homo_education std_homo_life_skills std_tie_synth_*
reshape long std_jobsearch_ std_contribute_ std_garner_ std_donate_ std_personalgain_ std_grpgain_ std_homo_pol_ std_homo_rel_ std_homo_educ_ std_homo_ls_ std_pers_cris_synth_ std_pers_succ_synth_ std_prof_cris_synth_ std_prof_succ_synth_ std_seat_synth2_lst_ std_seat_synth2_mst_ std_interaction_ std_tie_, i(ind) j(tie) string
saveold "./bisbee_larson_replication_final/tools/final_data_long.dta", replace
